package com.client.ryt.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Handler;
import android.os.Bundle;


import com.client.ryt.R;
import com.client.ryt.config.LoginConfig;
import com.client.ryt.utils.NetUtil;
import com.umeng.update.UmengUpdateAgent;

public class IndexActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_index);
        UmengUpdateAgent.setUpdateOnlyWifi(false);//仅在wifi环境下提示更新
        UmengUpdateAgent.update(this);//友盟自动更新
        if(!NetUtil.isNetworkAvailable()) {
            Intent intent = new Intent(IndexActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }else{
            if ((LoginConfig.getLoginConfig().getToken() != null)) {
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Intent intent = new Intent(IndexActivity.this, MainActivity.class);
                        startActivity(intent);
                        finish();
                    }
                }, 2500);
            } else {
                Intent intent = new Intent(IndexActivity.this, LoginActivity.class);
                startActivity(intent);
                finish();
            }
        }
    }



}
